﻿using FluentValidation;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Security.Principal;
using System.Text;

namespace Acme.BookStore.Books
{
    public class CreateUpdateBookDto // : IValidatableObject
    {
        [Required]
        [StringLength(128)]
        public string Name { get; set; }

        [Required]
        public BookType Type { get; set; } = BookType.Undefined;

        [Required]
        [DataType(DataType.Date)]
        public DateTime PublishDate { get; set; } = DateTime.Now;

        [Required]
        public float Price { get; set; }

        public Guid AuthorId { get; set; }

        public string Description { get; set; }

        //public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
        //{
        //    if (Name == Description)
        //    {
        //        yield return new ValidationResult(
        //            "Name and Description can not be the same!",
        //            new[] { "Name", "Description" }
        //        );
        //    }
        //}
    }
    //public class CreateUpdateBookDtoValidator : AbstractValidator<CreateUpdateBookDto>
    //{
    //    public CreateUpdateBookDtoValidator()
    //    {
    //        RuleFor(x => x.Name).Length(3, 10).WithMessage("WithMessage");
    //        RuleFor(x => x.Price).ExclusiveBetween(0.0f, 999.0f);
    //        RuleFor(x => x.Name).Must((d, p, r) =>
    //        {
    //            return d.Name != d.Description;
    //        }).WithMessage("Name and Description can not be the same!");
    //    }
    //}

}
